import ajax from './index'
import axios from 'axios'
import { append, appends } from './index'
//小店会员列表
export function shopvipList(url) {
  return ajax.get('/admin/shop/shop_vip/list?' + url)
}

//会员商品订单
export function orderUserProductOrderList(url) {
  return ajax.get('/admin/order/user/product_order/list?' + url)
}

//会员现金券订单
export function orderUserCashCouponOrderList(url) {
  return ajax.get('/admin/order/user/cash_coupon_order/list?' + url)
}

//用户信息
export function userProfileData(url) {
  return ajax.get('/admin/user/user_profile?' + url)
}

//已加入会员小店信息
export function userShopVipList(url) {
  return ajax.get('/admin/shop/user/shop_vip/list?' + url)
}

//禁用某条会员
export function shopVipDisable(url) {
  return ajax.post('/admin/shop/shop_vip/disable?' + url)
}
//移除某个用户所有会员
export function shopUserVipDisable(url) {
  return ajax.post('/admin/shop/user/shop_vip/disable?' + url)
}
//会员卡列表
export function cardXiList(data) {
  return ajax.post('/admin/card/xi/list', data)
}

//删除会员卡
export function cardXiDelete(data) {
  return ajax.post('/admin/card/xi/delete', data)
}

//会员卡详情
export function cardXiDetail(data) {
  return ajax.post('/admin/card/xi/detail', data)
}

//获取小程序二维码
export function cardXiQRcode(data) {
  return ajax.post('/admin/card/xi/qrcode', data)
}
//检车卡号段是否可用
export function cardXiCheck(data) {
  return ajax.post('/admin/card/xi/check', data)
}

//添加卡号段
export function cardXiAdd(data) {
  axios.defaults.timeout = 20000
  return ajax.post('/admin/card/xi/add', data)
}

//绑定卡号段
export function cardXiBind(data) {
  return ajax.post('/admin/card/xi/bind', data)
}

//用户充值记录
export function cardUserIdIncomeSearch(id, url) {
  return ajax.get('/admin/card/user/' + id + '/income/search?' + url)
}

//会员-所有会员卡退费
export function refundAllVipCardmoney(data) {
  return ajax.post('/admin/shop/vip_user/refund_all_vip_card_money', data)
}

//会员-会员卡退费
export function refundVipCardMoney(data) {
  return ajax.post('/admin/shop/vip_user/refund_vip_card_money', data)
}

//会员激励
export function userShopVipOrderList(url) {
  return ajax.get('/admin/shop/user/shop_vip/order/list?' + url)
}

//红包使用记录
export function userCardConsumeRecord(id, url) {
  return ajax.get('/admin/card/user/' + id + '/consume/search?' + url)
}
// 获取员工权限节点
export const getMemberPermissionMenu = () => {
  return ajax.get('/partner_admin/staff/role/config_permission')
}
// 获取员工角色列表
export const getMemberRoleList = data => {
  return ajax.get(`/partner_admin/staff/role/search${append(data)}`)
}
// 获取员工角色详情
export const getMemberRoleInfo = id => {
  return ajax.get(`/partner_admin/staff/role/${id}/get`)
}
// 添加员工角色
export const addMemberRole = data => {
  return ajax.post('/partner_admin/staff/role/insert', data)
}
// 编辑员工角色
export const updateMemberRole = data => {
  return ajax.post('/partner_admin/staff/role/update', data)
}
// 删除员工角色
export const deleteMemberRole = id => {
  return ajax.get(`/partner_admin/staff/role/${id}/delete`)
}
// 获取员工管理的小店列表
export const getMemberManageStoreList = (data) => {
  return ajax.get(`/partner_admin/shop/staff/management_shop/list${append(data)}`)
}
// 获取所有小店列表
export const getAllStoreList = data => {
  return ajax.get(
    `/partner_admin/shop/partner_simple_shops/search${append(data)}`
  )
}
// 员工详情
export const getMemberInfo = id => {
  return ajax.get(`partner_admin/staff/${id}/get`)
}
// 员工列表
// export const getMemberList = data => {
//   return ajax.get(`/partner_admin/staff/search${append(data)}`)
// }
export function getMemberList(query) {
  return ajax({
    url: `/backend/admin/list`,
    method: 'get',
    params: query
  });
}
// 创建员工
export const addMember = data => {
  return ajax.post('/partner_admin/staff/add', data)
}
// 编辑员工
export const updateMember = data => {
  return ajax.post('/partner_admin/staff/update', data)
}
// 删除员工
export const deleteMember = id => {
  return ajax.post(`/partner_admin/staff/${id}/delete`)
}
// 获取当前用户的权限
export const getCurrentPermission = () => {
  return ajax.get(`/partner_admin/staff/role/permission/get`)
}
// 获取当前用户的账号信息
export const getAccoountInfo = () => {
  return ajax.get(`/partner_admin/partner/areas/list`)
}

// 获取员工的收益信息
export const getMemberProfit = data => {
  return ajax.post(`partner_admin/staff/census/profit`, data)
}

// 获取员工的收益信息列表
export const getMemberProfitList = data => {
  return ajax.post(`partner_admin/staff/census/profit/search`, data)


}

// 获取账号详情
// export const getAccountInfo = () => {
//   return ajax.post('partner_admin/info')
// }

// 删除员工

// 服务经理管理小店列表
export function manageSellerList(query) {
  return ajax({
    url: '/backend/admin/manageSellerList',
    method: 'get',
    params: query
  });
}


export function adminDelete(ids) {
  return ajax({
    url: `/backend/admin/delete/${ids}`,
    method: 'POST'
  });
}

export function register(obj) {
  return ajax({
    url: '/backend/admin/register',
    method: 'post',
    data: obj
  });
}
// 登录以后返回token
export function login(obj) {
  return ajax({
    url: '/backend/admin/login',
    method: 'post',
    data: obj
  });
}
// 刷新token  refreshToken
export function refreshToken(query) {
  return ajax({
    url: '/backend/admin/refreshToken',
    method: 'get',
    params: query
  });
}
// 获取当前登录用户信息
export function getAdminInfo(obj) {
  return ajax({
    url: '/backend/admin/info',
    method: 'post',
    data: obj
  });
}
// 退出
export function logout(query) {
  return ajax({
    url: '/backend/admin/logout',
    method: 'get',
    params: query
  });
}
// 管理员列表
export function adminList(query) {
  return ajax({
    url: '/backend/admin/list',
    method: 'get',
    params: query
  });
}
// 管理员详情
export function adminInfo(id) {
  return ajax({
    url: `/backend/admin/${id}`,
    method: 'get'
  });
}
// 更新管理员
export function adminUpdate(obj) {
  return ajax({
    url: `/backend/admin/update/${obj.id}`,
    method: 'post',
    data: obj
  });
}
// 新增管理员
export function adminAdd(obj) {
  return ajax({
    url: '/backend/admin/add',
    method: 'post',
    data: obj
  });
}
// 更新管理员密码
export function updatePassword(obj) {
  return ajax({
    url: '/backend/admin/updatePassword',
    method: 'post',
    data: obj
  });
}
// 更新当前管理员密码
export function updateMyPassword(obj) {
  return ajax({
    url: '/backend/admin/updateMyPassword',
    method: 'post',
    data: obj
  });
}
// 删除管理员
// export function adminDelete(id) {
//   return ajax({
//     url: `/backend/admin/delete/${id}`,
//     method: 'post'
//   });
// }
// 更新管理员状态
export function updateStatus(obj, id) {
  return ajax({
    url: `/backend/admin/updateStatus/${id}?status=${obj.status}`,
    method: 'post'
  });
}
// 更新管理员角色
export function adminRoleUpdate(obj) {
  return ajax({
    url: '/backend/admin/role/update',
    method: 'post',
    data: obj
  });
}
// 获取管理员角色
export function getRole(id) {
  return ajax({
    url: `/backend/admin/role/${id}`,
    method: 'get'
  });
}
// 获取管理员菜单树
export function getListMenuNode(id) {
  return ajax({
    url: `/backend/admin/listMenuNode/${id}`,
    method: 'get'
  });
}
// 后台用户角色管理
// 新增
export function roleCreate(obj) {
  return ajax({
    url: '/backend/role/create',
    method: 'post',
    data: obj
  });
}
// 修改
export function roleUpdate(obj) {
  return ajax({
    url: `/backend/role/update/${obj.id}`,
    method: 'post',
    data: obj
  });
}
// 删除
export function roleDelete(obj) {
  return ajax({
    url: `/backend/role/delete?${obj}`,
    method: 'post',
    data: obj
  });
}
// 所有角色
export function roleListAll(query) {
  return ajax({
    url: '/backend/role/listAll',
    method: 'get',
    params: query
  });
}
// 角色分页列表
export function roleList(query) {
  return ajax({
    url: '/backend/role/list',
    method: 'get',
    params: query
  });
}
// 修改角色状态
export function roleUpdateStatus(obj) {
  return ajax({
    url: `/backend/role/updateStatus/${obj.id}?status=${obj.status}`,
    method: 'post',
    data: obj
  });
}
// 角色菜单列表
export function roleListMenu(roleId) {
  return ajax({
    url: `/backend/role/listMenu/${roleId}`,
    method: 'get'
  });
}
// 角色详情

export function roleDetails(roleId) {
  return ajax({
    url: `/backend/role/details/${roleId}`,
    method: 'POST'
  });
}
// 角色菜单树
export function roleListMenuNode(roleId) {
  return ajax({
    url: `/backend/role/listMenuNode/${roleId}`,
    method: 'get'
  });
}
// 保存角色菜单
export function roleAllocMenu(obj) {
  return ajax({
    url: '/backend/role/allocMenu',
    method: 'post',
    data: obj
  });
}


// 会员列表
export function member_list(condition) {
  return ajax({
    url: "/backend/member/list",
    method: "get",
    params: condition
  });
}


export function getAccountInfo(id) {
  return ajax({
    url: `/backend/admin/${id}`,
    method: "get"
  });
}

// // 更新管理员
// export function adminUpdate(obj) {
//   return ajax({
//     url: `/backend/admin/update/${obj.id}`,
//     method: 'post',
//     data: obj
//   });
// }